\(\int \cot ^2(e+f x) (a+b \sec ^2(e+f x))^2 \, dx\) [334]

   Optimal result
   Rubi [A] (verified)
   Mathematica [B] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [F]
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 23, antiderivative size = 36 \[ \int \cot ^2(e+f x) \left (a+b \sec ^2(e+f x)\right )^2 \, dx=-a^2 x-\frac {(a+b)^2 \cot (e+f x)}{f}+\frac {b^2 \tan (e+f x)}{f} \]

[Out]

-a^2*x-(a+b)^2*cot(f*x+e)/f+b^2*tan(f*x+e)/f

Rubi [A] (verified)

Time = 0.09 (sec) , antiderivative size = 36, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.130, Rules used = {4226, 1816, 209} \[ \int \cot ^2(e+f x) \left (a+b \sec ^2(e+f x)\right )^2 \, dx=a^2 (-x)-\frac {(a+b)^2 \cot (e+f x)}{f}+\frac {b^2 \tan (e+f x)}{f} \]

[In]

Int[Cot[e + f*x]^2*(a + b*Sec[e + f*x]^2)^2,x]

[Out]

-(a^2*x) - ((a + b)^2*Cot[e + f*x])/f + (b^2*Tan[e + f*x])/f

Rule 209

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*ArcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rule 1816

Int[(Pq_)*((c_.)*(x_))^(m_.)*((a_) + (b_.)*(x_)^2)^(p_.), x_Symbol] :> Int[ExpandIntegrand[(c*x)^m*Pq*(a + b*x
^2)^p, x], x] /; FreeQ[{a, b, c, m}, x] && PolyQ[Pq, x] && IGtQ[p, -2]

Rule 4226

Int[((a_) + (b_.)*sec[(e_.) + (f_.)*(x_)]^(n_))^(p_.)*((d_.)*tan[(e_.) + (f_.)*(x_)])^(m_), x_Symbol] :> With[
{ff = FreeFactors[Tan[e + f*x], x]}, Dist[ff/f, Subst[Int[(d*ff*x)^m*((a + b*(1 + ff^2*x^2)^(n/2))^p/(1 + ff^2
*x^2)), x], x, Tan[e + f*x]/ff], x]] /; FreeQ[{a, b, d, e, f, m, p}, x] && IntegerQ[n/2] && (IntegerQ[m/2] ||
EqQ[n, 2])

Rubi steps \begin{align*} \text {integral}& = \frac {\text {Subst}\left (\int \frac {\left (a+b \left (1+x^2\right )\right )^2}{x^2 \left (1+x^2\right )} \, dx,x,\tan (e+f x)\right )}{f} \\ & = \frac {\text {Subst}\left (\int \left (b^2+\frac {(a+b)^2}{x^2}-\frac {a^2}{1+x^2}\right ) \, dx,x,\tan (e+f x)\right )}{f} \\ & = -\frac {(a+b)^2 \cot (e+f x)}{f}+\frac {b^2 \tan (e+f x)}{f}-\frac {a^2 \text {Subst}\left (\int \frac {1}{1+x^2} \, dx,x,\tan (e+f x)\right )}{f} \\ & = -a^2 x-\frac {(a+b)^2 \cot (e+f x)}{f}+\frac {b^2 \tan (e+f x)}{f} \\ \end{align*}

Mathematica [B] (verified)

Leaf count is larger than twice the leaf count of optimal. \(82\) vs. \(2(36)=72\).

Time = 3.12 (sec) , antiderivative size = 82, normalized size of antiderivative = 2.28 \[ \int \cot ^2(e+f x) \left (a+b \sec ^2(e+f x)\right )^2 \, dx=-\frac {4 \left (b+a \cos ^2(e+f x)\right )^2 \sec (e+f x) \left (a^2 f x \cos (e+f x)-\left ((a+b)^2 \cot (e+f x) \csc (e)+b^2 \sec (e)\right ) \sin (f x)\right )}{f (a+2 b+a \cos (2 (e+f x)))^2} \]

[In]

Integrate[Cot[e + f*x]^2*(a + b*Sec[e + f*x]^2)^2,x]

[Out]

(-4*(b + a*Cos[e + f*x]^2)^2*Sec[e + f*x]*(a^2*f*x*Cos[e + f*x] - ((a + b)^2*Cot[e + f*x]*Csc[e] + b^2*Sec[e])
*Sin[f*x]))/(f*(a + 2*b + a*Cos[2*(e + f*x)])^2)

Maple [A] (verified)

Time = 1.89 (sec) , antiderivative size = 66, normalized size of antiderivative = 1.83

method result size
derivativedivides \(\frac {a^{2} \left (-\cot \left (f x +e \right )-f x -e \right )-2 a b \cot \left (f x +e \right )+b^{2} \left (\frac {1}{\sin \left (f x +e \right ) \cos \left (f x +e \right )}-2 \cot \left (f x +e \right )\right )}{f}\) \(66\)
default \(\frac {a^{2} \left (-\cot \left (f x +e \right )-f x -e \right )-2 a b \cot \left (f x +e \right )+b^{2} \left (\frac {1}{\sin \left (f x +e \right ) \cos \left (f x +e \right )}-2 \cot \left (f x +e \right )\right )}{f}\) \(66\)
risch \(-a^{2} x -\frac {2 i \left (a^{2} {\mathrm e}^{2 i \left (f x +e \right )}+2 a b \,{\mathrm e}^{2 i \left (f x +e \right )}+a^{2}+2 a b +2 b^{2}\right )}{f \left ({\mathrm e}^{2 i \left (f x +e \right )}-1\right ) \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )}\) \(79\)

[In]

int(cot(f*x+e)^2*(a+b*sec(f*x+e)^2)^2,x,method=_RETURNVERBOSE)

[Out]

1/f*(a^2*(-cot(f*x+e)-f*x-e)-2*a*b*cot(f*x+e)+b^2*(1/sin(f*x+e)/cos(f*x+e)-2*cot(f*x+e)))

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 67, normalized size of antiderivative = 1.86 \[ \int \cot ^2(e+f x) \left (a+b \sec ^2(e+f x)\right )^2 \, dx=-\frac {a^{2} f x \cos \left (f x + e\right ) \sin \left (f x + e\right ) + {\left (a^{2} + 2 \, a b + 2 \, b^{2}\right )} \cos \left (f x + e\right )^{2} - b^{2}}{f \cos \left (f x + e\right ) \sin \left (f x + e\right )} \]

[In]

integrate(cot(f*x+e)^2*(a+b*sec(f*x+e)^2)^2,x, algorithm="fricas")

[Out]

-(a^2*f*x*cos(f*x + e)*sin(f*x + e) + (a^2 + 2*a*b + 2*b^2)*cos(f*x + e)^2 - b^2)/(f*cos(f*x + e)*sin(f*x + e)
)

Sympy [F]

\[ \int \cot ^2(e+f x) \left (a+b \sec ^2(e+f x)\right )^2 \, dx=\int \left (a + b \sec ^{2}{\left (e + f x \right )}\right )^{2} \cot ^{2}{\left (e + f x \right )}\, dx \]

[In]

integrate(cot(f*x+e)**2*(a+b*sec(f*x+e)**2)**2,x)

[Out]

Integral((a + b*sec(e + f*x)**2)**2*cot(e + f*x)**2, x)

Maxima [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 46, normalized size of antiderivative = 1.28 \[ \int \cot ^2(e+f x) \left (a+b \sec ^2(e+f x)\right )^2 \, dx=-\frac {{\left (f x + e\right )} a^{2} - b^{2} \tan \left (f x + e\right ) + \frac {a^{2} + 2 \, a b + b^{2}}{\tan \left (f x + e\right )}}{f} \]

[In]

integrate(cot(f*x+e)^2*(a+b*sec(f*x+e)^2)^2,x, algorithm="maxima")

[Out]

-((f*x + e)*a^2 - b^2*tan(f*x + e) + (a^2 + 2*a*b + b^2)/tan(f*x + e))/f

Giac [A] (verification not implemented)

none

Time = 0.32 (sec) , antiderivative size = 46, normalized size of antiderivative = 1.28 \[ \int \cot ^2(e+f x) \left (a+b \sec ^2(e+f x)\right )^2 \, dx=-\frac {{\left (f x + e\right )} a^{2} - b^{2} \tan \left (f x + e\right ) + \frac {a^{2} + 2 \, a b + b^{2}}{\tan \left (f x + e\right )}}{f} \]

[In]

integrate(cot(f*x+e)^2*(a+b*sec(f*x+e)^2)^2,x, algorithm="giac")

[Out]

-((f*x + e)*a^2 - b^2*tan(f*x + e) + (a^2 + 2*a*b + b^2)/tan(f*x + e))/f

Mupad [B] (verification not implemented)

Time = 19.06 (sec) , antiderivative size = 44, normalized size of antiderivative = 1.22 \[ \int \cot ^2(e+f x) \left (a+b \sec ^2(e+f x)\right )^2 \, dx=\frac {b^2\,\mathrm {tan}\left (e+f\,x\right )}{f}-a^2\,x-\frac {a^2+2\,a\,b+b^2}{f\,\mathrm {tan}\left (e+f\,x\right )} \]

[In]

int(cot(e + f*x)^2*(a + b/cos(e + f*x)^2)^2,x)

[Out]

(b^2*tan(e + f*x))/f - a^2*x - (2*a*b + a^2 + b^2)/(f*tan(e + f*x))